aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pages/kodaira-data/events/[...path].astro
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-05 14:58:06 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-05 14:58:06 +0900
commite7b60d5ef8c8cf5471a62498fd0a88f61cd2812e (patch)
tree7a7033fc634baa1d7695dd52e90961e98cfc5e16 /src/pages/kodaira-data/events/[...path].astro
parent3e02a6a05c6a5b26fbb19fa91be9afbc6b12877d (diff)
events: メインは前月以降、アーカイブは前々月以前に分ける
メインページの一覧とカレンダーを前月以降に広げ、前々月以前の月だけを アーカイブとして生成するようにした。該当が無いときはアーカイブ欄に その旨を表示する。月が進めば自動でページが増える。 RSSと旧URLの転送先も、存在しない月ページを指さないよう合わせた。
Diffstat (limited to 'src/pages/kodaira-data/events/[...path].astro')
-rw-r--r--src/pages/kodaira-data/events/[...path].astro13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/pages/kodaira-data/events/[...path].astro b/src/pages/kodaira-data/events/[...path].astro
index e09cc30..0eb438b 100644
--- a/src/pages/kodaira-data/events/[...path].astro
+++ b/src/pages/kodaira-data/events/[...path].astro
@@ -2,12 +2,21 @@
// 旧URL(/kodaira-data/events/2026-11/ など)から新しいURLへの転送。
// 本番のApacheは public/.htaccess が301で返す。astro dev / preview では
// .htaccess が効かないため、ここで同じ転送を用意しておく。
-import { fiscalYearKeys, monthKeys } from '@/lib/schedule-months';
+import {
+ archiveFiscalYearKeys,
+ archiveMonthKeys,
+ fiscalYearKeys,
+ monthKeys,
+} from '@/lib/schedule-months';
+import { SCHEDULE_BASE_PATH } from '@/data/schedule/config';
export function getStaticPaths() {
return [...monthKeys, ...fiscalYearKeys].map((path) => ({ params: { path } }));
}
+// アーカイブにある期間はそのページへ、まだアーカイブに移していない期間は
+// メインページ(前月以降を掲載)へ送る。
const { path } = Astro.params;
-return Astro.redirect(`/kodaira/events/${path}/`, 301);
+const archived = [...archiveMonthKeys, ...archiveFiscalYearKeys].includes(path ?? '');
+return Astro.redirect(archived ? `${SCHEDULE_BASE_PATH}${path}/` : SCHEDULE_BASE_PATH, 301);
---